package com.device.search.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.device.search.model.Device;
import com.device.search.model.DeviceStatus;

public interface ConstructionDeviceMapper {

	@Select("SELECT d.construction_id,d.id,b.project_name,d.dvice_no FROM construction_basic b,construction_device d " + 
			"WHERE b.id=d.construction_id AND b.project_name LIKE CONCAT(CONCAT('%',#{projectname},'%')) AND d.dvice_no LIKE CONCAT(CONCAT('%',#{deviceNo},'%'))")
	List<Device> findByProjectNameAndDeviceNo(@Param("projectname") String projectname, @Param("deviceNo") String deviceNo);

	@Select("SELECT d.construction_id,d.id,b.project_name,d.dvice_no,s.name,s.mobile,d.pid FROM construction_basic b LEFT JOIN construction_device d ON b.id=d.construction_id LEFT JOIN construction_contacts s ON b.id=s.construction_id \r\n" + 
			"WHERE b.project_name LIKE CONCAT(CONCAT('%',#{projectname},'%')) AND d.dvice_no LIKE CONCAT(CONCAT('%',#{deviceNo},'%'))")
	List<DeviceStatus> findDeviceStatus(@Param("projectname") String projectname, @Param("deviceNo") String deviceNo);

}

